Skip to content

Add request ID tracking to token validation for support correlation - #6821

Merged
Kastier1 merged 3 commits into
mainfrom
claude/reflex-cli-auth-request-id-xjg996
Jul 31, 2026
Merged

Add request ID tracking to token validation for support correlation#6821
Kastier1 merged 3 commits into
mainfrom
claude/reflex-cli-auth-request-id-xjg996

Conversation

@Kastier1

@Kastier1 Kastier1 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Type of change

  • New feature (non-breaking change which adds functionality)

Description

This PR adds request ID tracking to token validation requests to enable support teams to correlate failed authentications with server-side logs.

Changes:

  1. New get_auth_request_id() function in hosting.py: Returns the request ID from the most recent token validation request, allowing callers to retrieve it for support correlation.

  2. Enhanced validate_token() function:

    • Generates a unique request ID (uuid.uuid4().hex) for each validation request
    • Sends the request ID as the X-Request-ID header to the control plane
    • Includes the request ID in all debug log messages for traceability
  3. Improved validate_token_with_retries() error handling:

    • "Access denied" errors now include the request ID in error messages
    • Network/server errors now include the request ID in warning messages
    • Enables users to quote the request ID to support for log correlation
  4. Comprehensive test coverage:

    • test_validate_token_sends_request_id_header: Verifies each validation request carries a fresh request ID header
    • test_validate_token_with_retries_warns_with_request_id: Confirms failed validations surface the request ID in warnings
    • test_validate_token_with_retries_access_denied_reports_request_id: Validates access denied errors include the request ID

Testing

  • Added 3 new unit tests covering request ID generation, header transmission, and error reporting
  • All tests pass and verify the request ID is properly tracked and included in error messages
  • Existing tests continue to pass

Checklist

  • Changes follow the guidelines in CONTRIBUTING.md
  • Tests added for new functionality
  • Code is linted and formatted
  • No breaking changes introduced

https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2

Greptile Summary

Adds per-request authentication correlation IDs.

  • Generates a fresh UUID for each token-validation request and sends it in the X-Request-ID header.
  • Exposes the latest authentication request ID and includes it in validation diagnostics.
  • Adds tests for header transmission, ID freshness, and failed-authentication messages.

Confidence Score: 5/5

The PR appears safe to merge with no actionable defects identified.

The synchronous token-validation path assigns the request ID before making the HTTP request, uses that same ID in the request header, and surfaces it on each reachable failure path.

Important Files Changed

Filename Overview
packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py Adds request-ID generation, transmission, retrieval, and diagnostic reporting without an identified reachable defect.
tests/units/reflex_cli/utils/test_hosting.py Adds focused coverage for unique request IDs and their inclusion in authentication failure messages.

Reviews (1): Last reviewed commit: "Send X-Request-ID with token validation ..." | Re-trigger Greptile

Tag every call to /api/v1/authenticate/me with a client-generated
X-Request-ID header and quote it in the (now visible) warning/error when
validation fails, so intermittent auth failures can be correlated with
control-plane logs. Expose the id via get_auth_request_id() for
downstream packages (e.g. reflex-enterprise) to include in their own
error messages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2
@codspeed-hq

codspeed-hq Bot commented Jul 29, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing claude/reflex-cli-auth-request-id-xjg996 (1f3fafc) with main (e3fe1a1)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2
@Kastier1
Kastier1 marked this pull request as ready for review July 31, 2026 19:36
@Kastier1
Kastier1 requested a review from a team as a code owner July 31, 2026 19:36
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds request-ID correlation to hosting token validation.

  • Generates and sends a fresh X-Request-ID with each validation request.
  • Preserves request IDs on validation exceptions and surfaces them in authentication failure messages.
  • Adds unit coverage and a release-note entry for the new behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/reflex-hosting-cli/src/reflex_cli/utils/exceptions.py Adds request-aware validation and access-denied exception types while retaining ValueError compatibility for denied tokens.
packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py Generates, transmits, tracks, and reports request IDs throughout token validation failure handling.
tests/units/reflex_cli/utils/test_hosting.py Covers request-ID uniqueness, header transmission, warning output, access-denied output, and exception metadata.
packages/reflex-hosting-cli/news/6821.feature.md Documents request-ID correlation for failed token validations.

Reviews (3): Last reviewed commit: "Carry request id on token validation exc..." | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread packages/reflex-hosting-cli/src/reflex_cli/utils/hosting.py
Comment thread packages/reflex-hosting-cli/news/6821.feature.md Outdated
Address review: the process-global last-request-id could misreport
under concurrent validations. validate_token now raises
TokenValidationError / TokenAccessDeniedError (backward compatible
with Exception / ValueError) carrying the request id of their own
request, and validate_token_with_retries prefers that over the global.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CuGeE8ncgcXTmCTfuP3DE2
@Kastier1
Kastier1 merged commit 93649a1 into main Jul 31, 2026
108 checks passed
@Kastier1
Kastier1 deleted the claude/reflex-cli-auth-request-id-xjg996 branch July 31, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants